<template>
  <div class="search-bar">
    <el-form :inline="true" :model="formItem" size="mini" class="form-filter">
      <el-form-item label="">
        <el-input
          v-model="formItem.s_kw"
          placeholder="请输入关键字..."
          clearable
          @keyup.enter.native="search"
          @change="onMixedInputChange"
        />
      </el-form-item>
      <el-form-item>
        <el-button plain icon="el-icon-search" @click="search" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
// 定义一个查询表单原始项
const formItem = {
  s_kw: ''
}

export default {
  name: 'SchemasTableFilter',
  props: {
    inactive: {
      type: Boolean,
      default: true
    },
    kw: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      formItem: { ...formItem, s_kw: this.kw }
    }
  },
  methods: {
    // 复合型输入框 input 值改变事件
    onMixedInputChange(value) {
      if (value !== '') {
        this.search()
      }
    },
    // 查询按钮点击事件处理
    search: function() {
      this.$emit('on-filter', this.formItem)
    },
    onChange: function(val) {
      this.$parent.onResize()
    },
    exportExcel() {
      this.$emit('on-export', this.formItem)
    }
  }
}
</script>
